<?php
if (!$step) { header('Location: ./install.php'); die(); }
echo '<div class="instructions">';
$file='../config.php';
if (!file_exists($file)) { $errors[]="'$file' was not found! This is a fatal error."; }
elseif (filesize($file) <= 0) { $errors[]="'$file' is 0 bytes! This is a fatal error."; }

$file='../settings.php';
if (!file_exists($file)) { $errors[]="'$file' was not found! Try renaming 'settings.php.default' to 'settings.php'"; }
elseif (filesize($file) <= 0) { $errors[]="'$file' is 0 bytes!"; }
elseif (!is_writable($file)) { $errors[]="'$file' is not writable! Please chmod this file to 777 while editing."; }

define("mnminclude", dirname(__FILE__).'/../libs/');
include_once mnminclude.'db.php';
include_once mnminclude.'html1.php';

// Check user input here
if (!$_POST['godlogin'] ||
    !$_POST['godpassword'] ||
    !$_POST['godemail'])
    	$errors[] = $lang['Error5-1'];
elseif ($_POST['godpassword'] != $_POST['godpassword2'])
    	$errors[] = $lang['Error5-2'];
		
if (!$errors) {
	include_once( '../config.php' );
	include_once( '../libs/admin_config.php' );
	
	echo "Adding the Admin user account...<br />";
	$userip=$_SERVER['REMOTE_ADDR'];
	$saltedpass=generateHash($_POST['godpassword']);
	$sql = "INSERT INTO `" . table_users . "` VALUES (1, '".$db->escape($_POST['godlogin'])."', 'god', now(), now(), '$saltedpass', '".$db->escape($_POST['godemail'])."', '', 10.00, 'www.pligg.com', now(), '', '', '', '', '', '', '', '', '0', '0', now(), now(), '', '', '', '1');";
	$db->query( $sql );

	//done
	$output='<p><strong><a href="../">Your Pligg Site</a> appears to have installed successfully!</strong></p>
	<br /><h2>What to do next:</strong></h2>
	<div class="donext"><ol>
		<li><p>chmod "/libs/dbconnect.php" back to 644, we will not need to change this file again.</p></li>
		<li><p><strong>DELETE</strong> the "/install" directory from your server if you have successfully installed Pligg.</p></li>
		<li><p>Login to the <a href="../admin/admin_index.php">admin area</a> (username: '.$_POST['godlogin'].'; password: '.$_POST['godpassword'].'). Once you log in you should be presented with more information about how to use Pligg.</p></li>
		<li><p><a href="../admin/admin_config.php">Configure your site</a> using the admin area.</p></li>
		<li><p>Visit the <a href="http://forums.pligg.com/">Pligg Forums</a> if you have any questions, or just to tell us about your new site.</p></li>
	</ol></div>';
}

if (isset($errors)) {
	$output=DisplayErrors($errors);
	$output.='<p>' . $lang['Errors'] . '</p>';
}

echo $output;
echo '</div>';

?>
